import os
print('begin');
PATH_TO_ALL_JSON = 'somejson'
RESULT_JSON_NAME = 'result.txt'

#get list all files
files = os.listdir(PATH_TO_ALL_JSON)
#get all json files
jsonfiles = filter(lambda x: x.endswith('.json'), files)
#add ignore result file
resultdata = '['
for f in jsonfiles: 
    onefile = open(PATH_TO_ALL_JSON+"/"+f, 'r')
    print('file >', f);
    onefilestring = onefile.read() 
    onefilestring = onefilestring.replace('\n','')
    onefilestring = onefilestring.replace('\t','')
    resultdata+='{"'+f[:-5] + '":' + onefilestring +  '},\n'
	
#delete last ',\n' symbol 
resultdata = resultdata [:-2]
resultdata+=']'

#write result file
resultfile = open(PATH_TO_ALL_JSON + "/" + RESULT_JSON_NAME, 'w')
resultfile.write(resultdata)
resultfile.close()
print('end');

